home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_enscript.idb / usr / freeware / share / enscript / hl / javascript.st.z / javascript.st
Encoding:
Text File  |  2002-04-08  |  2.5 KB  |  124 lines

  1. /**
  2.  * Name: javascript
  3.  * Description: JavaScript language.
  4.  * Author: Markku Rossi <mtr@iki.fi>
  5.  */
  6.  
  7. from_vrml = 0;
  8.  
  9. state javascript_string extends Highlight
  10. {
  11.   /\\\\./ {
  12.     language_print ($0);
  13.   }
  14.   /[\']/ {
  15.     language_print ($0);
  16.     return;
  17.   }
  18. }
  19.  
  20. state javascript_internal extends Highlight
  21. {
  22.   /* Comments. */
  23.   /\/\*/ {
  24.     comment_face (true);
  25.     language_print ($0);
  26.     call (c_comment);
  27.     comment_face (false);
  28.   }
  29.   /\/\// {
  30.     comment_face (true);
  31.     language_print ($0);
  32.     call (eat_one_line);
  33.     comment_face (false);
  34.   }
  35.  
  36.   /* String constants. */
  37.   /\"/ {
  38.     if (from_vrml)
  39.       {
  40.     reference_face (true);
  41.     language_print ($0);
  42.     reference_face (false);
  43.     return;
  44.       }
  45.     string_face (true);
  46.     language_print ($0);
  47.     call (c_string);
  48.     string_face (false);
  49.   }
  50.  
  51.   /* '' strings. */
  52.   /[\']/ {
  53.     string_face (true);
  54.     language_print ($0);
  55.     call (javascript_string);
  56.     string_face (false);
  57.   }
  58.  
  59.   /* Function definitions. */
  60.   /\b(function)([ \t]+)([A-Za-z\$_][A-Za-z\$_0-9]*)([ \t]*\()/ {
  61.     keyword_face (true);
  62.     language_print ($1);
  63.     keyword_face (false);
  64.  
  65.     language_print ($2);
  66.  
  67.     function_name_face (true);
  68.     language_print ($3);
  69.     function_name_face (false);
  70.  
  71.     language_print ($4);
  72.   }
  73.  
  74.   /* Keywords.
  75.      (build-re '(
  76.      abstract boolean break byte case catch char class const continue
  77.      default do double else extends false final finally float for function
  78.      goto if implements import in instanceof int interface long native new
  79.      null package private protected public return short static super switch
  80.      synchronized this throw throws transient true try var void while with
  81.      ))
  82.    */
  83.   /\b(abstract|b(oolean|reak|yte)|c(a(se|tch)|har|lass|on(st|tinue))\
  84. |d(efault|o(|uble))|e(lse|xtends)|f(alse|inal(|ly)|loat|or|unction)\
  85. |goto|i(f|mp(lements|ort)|n(|stanceof|t(|erface)))|long\
  86. |n(ative|ew|ull)|p(ackage|r(ivate|otected)|ublic)|return\
  87. |s(hort|tatic|uper|witch|ynchronized)|t(h(is|row(|s))|r(ansient|ue|y))\
  88. |v(ar|oid)|w(hile|ith))\b/ {
  89.     keyword_face (true);
  90.     language_print ($0);
  91.     keyword_face (false);
  92.   }
  93.  
  94.   /* Built-in objects.
  95.      (build-re '(Math Date eval parseInt parseFloat))
  96.    */
  97.   /\b(Date|Math|eval|parse(Float|Int))\b/ {
  98.     builtin_face (true);
  99.     language_print ($0);
  100.     builtin_face (false);
  101.   }
  102.  
  103.   /* Terminator for nested JavaScript programs. */
  104.   /<\/[sS][cC][rR][iI][pP][tT]>/ {
  105.     from_html_terminator = $0;
  106.     return;
  107.   }
  108. }
  109.  
  110. state javascript extends HighlightEntry
  111. {
  112.   BEGIN {
  113.     call (javascript_internal);
  114.     return;
  115.   }
  116. }
  117.  
  118.  
  119. /*
  120. Local variables:
  121. mode: c
  122. End:
  123. */
  124.